From: Alexander Larsson Date: Mon, 13 Aug 2018 15:44:27 +0000 (+0200) Subject: Fix leak in ostree_repo_list_collection_refs X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~20^2~19 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=016cae15732e8a6e0d6211c7f790b24e55f1f7cb;p=ostree.git Fix leak in ostree_repo_list_collection_refs We need to have the g_auto(GLnxDirFdIterator) inside the loop, or we don't correctly clean up when iterating several times. Closes: #1700 Approved by: cgwalters --- diff --git a/src/libostree/ostree-repo-refs.c b/src/libostree/ostree-repo-refs.c index b38489c4..1bbe3901 100644 --- a/src/libostree/ostree-repo-refs.c +++ b/src/libostree/ostree-repo-refs.c @@ -1251,7 +1251,6 @@ ostree_repo_list_collection_refs (OstreeRepo *self, (GDestroyNotify) ostree_collection_ref_free, g_free); - g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; g_autoptr(GString) base_path = g_string_new (""); const gchar *main_collection_id = ostree_repo_get_collection_id (self); @@ -1277,6 +1276,8 @@ ostree_repo_list_collection_refs (OstreeRepo *self, { const char *refs_dir = *iter; gboolean refs_dir_exists = FALSE; + g_auto(GLnxDirFdIterator) dfd_iter = { 0, }; + if (!ot_dfd_iter_init_allow_noent (self->repo_dir_fd, refs_dir, &dfd_iter, &refs_dir_exists, error)) return FALSE;